cmake_minimum_required(VERSION 3.31)
project(db)

set(CMAKE_CXX_STANDARD 20)
set(VCPKG e:/vcpkg/installed/x64-windows)
#set(CMAKE_PREFIX_PATH ${VCPKG})
set(ZLIB_LIBRARY ${VCPKG}/lib/zlib.lib)
set(ZLIB_INCLUDE_DIR ${VCPKG}/include)

# 找到 OpenSSL（MSYS2 UCRT64 包装好的）
#find_package(OpenSSL REQUIRED)
# 查找 PCRE2
find_package(ZLIB REQUIRED)
find_package(ZeroMQ CONFIG REQUIRED)

#find_package(PCRE2 REQUIRED)
#find_package(Poco REQUIRED COMPONENTS Redis Net Util Foundation Data DataMySQL)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)

message("CMAKE_SOURCE_DIR:${CMAKE_SOURCE_DIR}")
message("CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}")

# 检查并设置默认构建类型
if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
  message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to Debug")
endif()

# 根据构建类型设置编译选项
string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lower)

if(build_type_lower STREQUAL "debug")
    SET(POCO_LIBRARYS "pcre2-8.lib" "PocoFoundationd.lib" "PocoCryptod.lib" "PocoNetSSLd.lib" "PocoNetd.lib")
elseif(build_type_lower STREQUAL "release")
    SET(POCO_LIBRARYS "pcre2-8.lib" "PocoFoundation.lib" "PocoCrypto.lib" "PocoNetSSL.lib" "PocoNet.lib")
endif()

add_executable(db ../common/database.cpp dbserver.cpp ../common/RedisClient.cpp ../common/str.cpp ../common/AppDirectory.cpp ../common/KedisConfig.cpp)
#target_compile_options(db PRIVATE -Wa,-mbig-obj)
target_link_directories(db PRIVATE ${VCPKG}/lib)
target_include_directories(db PRIVATE ${VCPKG}/include ../common)

#target_link_libraries(reverse_proxy boost_json-mt ws2_32 mswsock)

# 给你的可执行目标链接
target_link_libraries(db
        PRIVATE
        ${POCO_LIBRARYS}
#        Poco::Redis
#        Poco::Net
#        Poco::Util
#        Poco::Foundation
#        Poco::Data
#        Poco::DataMySQL
        libzmq
        ws2_32 mswsock       # 你已有的 Windows 库
#        mariadbclient
        libmariadb
)